#ifndef _TASK_H_
#define _TASK_H_

#include <time.h>
#define MAX_TIMES 16
#define MAX_TAGS  16

struct task_header_tags
{
    char * tags[MAX_TAGS];
    int  count;
};


struct task_header
{
    int    level;
    char * state;
    char * caption;
    char   priority;
    
    int  completion;

    struct task_header_tags tags;
};

struct task_body_time
{
    char   type;
    time_t timestamp;
};

struct task_body_times
{
    struct task_body_time times[MAX_TIMES];
    int count;
};

struct task_body
{
    char * text;
    struct task_body_times times;
    
};

struct task;

struct task
{
    struct task_header * header;
    struct task_body   * body;
    
    struct task        * _next;
    struct task        * _parent;
    struct task        * _child;
};

struct task_list
{
    struct task * first;
    struct task * last;
    
};


struct task_list * new_task_list();

struct task_list * add_task_to_list(struct task_list * task_list,
                                    struct task * task);

struct task * new_task(struct task_header * header,
                       struct task_body   * body);

struct task_body * new_task_body(char * text);

struct task_header * new_task_header();

struct task_body * add_date_to_body(struct task_body * body, time_t time, char type);

struct task_body * add_text_to_body(struct task_body * body, const char * text);

struct task_header * add_level_to_header(struct task_header * dst, int level);

struct task_header * add_state_to_header(struct task_header * dst, const char * state);

struct task_header * add_caption_to_header(struct task_header * dst, const char * caption);

struct task_header * append_caption_to_header(struct task_header * dst, const char * caption);

struct task_header * add_priority_to_header(struct task_header * dst, char priority);

struct task_header * add_completion_to_header(struct task_header * dst, int completion);

void print_tasks(struct task_list * tasks);

void print_task(struct task * task);

void free_task(struct task * task);



#endif /* _TASK_H_ */
